package ui
{
	import flash.display.Graphics;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.ui.Mouse;

	public class ShopDialog extends Dialog
	{
		public var h:int = UIShopDialogItem.H * (1.2 * 2 + 0.2);
		public var w:int = UIShopDialogItem.W * (1.2 * 3 + 0.2);
		public var itemCount:int = 6;
		public var items:Vector.<UIShopDialogItem> = new Vector.<UIShopDialogItem>(itemCount);
		public var onSelect:Function;
		public var tabs:UIRadioTabGroup;
		public var bg:Sprite;
		public var itemLayer:Sprite = new Sprite();		
		
		public function ShopDialog()
		{
			super();
			var hTab:int = 40;
			var wTab:int = 100;
			tabs = new UIRadioTabGroup(4, wTab, hTab);
			tabs.x = (w-tabs.width)/2;
			drawBG();
			bg.y = hTab;
			addChild(tabs);
			addChild(bg);
			for (var i:int = 0; i < items.length; i++) {
				items[i] = new UIShopDialogItem;
				items[i].x = (i % (itemCount/2)) * (UIShopDialogItem.W*1.2);
				items[i].y = int(i / (itemCount/2)) * (UIShopDialogItem.H*1.2);
				itemLayer.addChild(items[i]);
			}
			itemLayer.x = UIShopDialogItem.W * 0.2;
			itemLayer.y = bg.y + UIShopDialogItem.H * 0.2;
			addChild(itemLayer);			
		}
		
		public function drawBG():void {
			bg = new Sprite();
			var g:Graphics = bg.graphics;
			g.lineStyle(4, 0xE0C290);
			g.beginFill(0xbe9962);
			g.drawRoundRect(0, 0, w, h, 40, 40);
			g.endFill();
		}
		
		override public function onActive():void {
			tabs.onActive();
		}
		
		override public function onUnActive():void {

		}

	}
}